package filter1;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "filter1.Filter2")
public class Filter2 implements Filter {
    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest req1=(HttpServletRequest)req;
        HttpServletResponse res1=(HttpServletResponse)resp;
        String token=req.getParameter("token");
        if(token!=null){
            chain.doFilter(req1, res1);
        }
        else{
            res1.getWriter().write("登录失败");

        }

    }

    public void init(FilterConfig config) throws ServletException {

    }

}
